package com.lyun.vo;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class PageVO<T> implements Serializable {
    /**
     * 总记录数
     */
    private Long counts = 0L;
    /**
     * 每页显示条数
     */
    private Integer pageSize = 0;
    /**
     * 总页数
     */
    private Long pages = 0L;
    /**
     * 分页页码
     */
    private Integer page = 0;
    /**
     * 数据
     */
    private List<T> items;

    public PageVO() {
    }

    public PageVO(Page<T> page) {
        this.counts = page.getTotal();
        this.pages = page.getPages();
        this.items = page.getRecords();
        this.pageSize = Math.toIntExact(page.getSize());
    }

}
